home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / cvs-1_3.lha / cvs-1.3 / src / log.c < prev    next >
C/C++ Source or Header  |  1992-03-31  |  3KB  |  133 lines

  1. /*
  2.  * Copyright (c) 1992, Brian Berliner and Jeff Polk
  3.  * Copyright (c) 1989-1992, Brian Berliner
  4.  * 
  5.  * You may distribute under the terms of the GNU General Public License as
  6.  * specified in the README file that comes with the CVS 1.3 kit.
  7.  * 
  8.  * Print Log Information
  9.  * 
  10.  * Prints the RCS "log" (rlog) information for the specified files.  With no
  11.  * argument, prints the log information for all the files in the directory
  12.  * (recursive by default).
  13.  */
  14.  
  15. #include "cvs.h"
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "@(#)log.c 1.39 92/03/31";
  19. #endif
  20.  
  21. #if __STDC__
  22. static Dtype log_dirproc (char *dir, char *repository, char *update_dir);
  23. static int log_fileproc (char *file, char *update_dir, char *repository,
  24.              List * entries, List * srcfiles);
  25. #else
  26. static int log_fileproc ();
  27. static Dtype log_dirproc ();
  28. #endif                /* __STDC__ */
  29.  
  30. static char options[PATH_MAX];
  31.  
  32. static char *log_usage[] =
  33. {
  34.     "Usage: %s %s [-l] [rlog-options] [files...]\n",
  35.     "\t-l\tLocal directory only, no recursion.\n",
  36.     NULL
  37. };
  38.  
  39. int
  40. cvslog (argc, argv)
  41.     int argc;
  42.     char *argv[];
  43. {
  44.     int i;
  45.     int numopt = 1;
  46.     int err = 0;
  47.     int local = 0;
  48.  
  49.     if (argc == -1)
  50.     usage (log_usage);
  51.  
  52.     /*
  53.      * All 'log' command options except -l are passed directly on to 'rlog'
  54.      */
  55.     options[0] = '\0';            /* Assume none */
  56.     for (i = 1; i < argc; i++)
  57.     {
  58.     if (argv[i][0] == '-' || argv[i][0] == '\0')
  59.     {
  60.         numopt++;
  61.         switch (argv[i][1])
  62.         {
  63.         case 'l':
  64.             local = 1;
  65.             break;
  66.         default:
  67.             (void) strcat (options, " ");
  68.             (void) strcat (options, argv[i]);
  69.             break;
  70.         }
  71.     }
  72.     }
  73.     argc -= numopt;
  74.     argv += numopt;
  75.  
  76.     err = start_recursion (log_fileproc, (int (*) ()) NULL, log_dirproc,
  77.                (int (*) ()) NULL, argc, argv, local,
  78.                W_LOCAL | W_REPOS | W_ATTIC, 0, 1,
  79.                (char *) NULL, 1);
  80.     return (err);
  81. }
  82.  
  83. /*
  84.  * Do an rlog on a file
  85.  */
  86. /* ARGSUSED */
  87. static int
  88. log_fileproc (file, update_dir, repository, entries, srcfiles)
  89.     char *file;
  90.     char *update_dir;
  91.     char *repository;
  92.     List *entries;
  93.     List *srcfiles;
  94. {
  95.     Node *p;
  96.     RCSNode *rcsfile;
  97.     int retcode = 0;
  98.  
  99.     p = findnode (srcfiles, file);
  100.     if (p == NULL || (rcsfile = (RCSNode *) p->data) == NULL)
  101.     {
  102.     if (!really_quiet)
  103.         error (0, 0, "nothing known about %s", file);
  104.     return (1);
  105.     }
  106.  
  107.     run_setup ("%s%s %s", Rcsbin, RCS_RLOG, options);
  108.     run_arg (rcsfile->path);
  109.     if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_REALLY)) == -1)
  110.     {
  111.     error (1, errno, "fork failed for rlog on %s", file);
  112.     }
  113.     return (retcode);
  114. }
  115.  
  116. /*
  117.  * Print a warm fuzzy message
  118.  */
  119. /* ARGSUSED */
  120. static Dtype
  121. log_dirproc (dir, repository, update_dir)
  122.     char *dir;
  123.     char *repository;
  124.     char *update_dir;
  125. {
  126.     if (!isdir (dir))
  127.     return (R_SKIP_ALL);
  128.  
  129.     if (!quiet)
  130.     error (0, 0, "Logging %s", update_dir);
  131.     return (R_PROCESS);
  132. }
  133.